package com.ruoyi.consent.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.consent.domain.AlgsEquipmentConsent;
import com.ruoyi.consent.service.IAlgsEquipmentConsentService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 器材审批Controller
 * 
 * @author ruoyi
 * @date 2023-03-21
 */
@RestController
@RequestMapping("/consent")
public class AlgsEquipmentConsentController extends BaseController
{
    @Autowired
    private IAlgsEquipmentConsentService algsEquipmentConsentService;

    /**
     * 查询器材审批列表
     */
//    @RequiresPermissions("consent:consent:list")
    @GetMapping("/list")
    public TableDataInfo list(AlgsEquipmentConsent algsEquipmentConsent)
    {
        startPage();
        List<AlgsEquipmentConsent> list = algsEquipmentConsentService.selectAlgsEquipmentConsentList(algsEquipmentConsent);
        return getDataTable(list);
    }

    /**
     * 导出器材审批列表
     */
//    @RequiresPermissions("consent:consent:export")
    @Log(title = "器材审批", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AlgsEquipmentConsent algsEquipmentConsent)
    {
        List<AlgsEquipmentConsent> list = algsEquipmentConsentService.selectAlgsEquipmentConsentList(algsEquipmentConsent);
        ExcelUtil<AlgsEquipmentConsent> util = new ExcelUtil<AlgsEquipmentConsent>(AlgsEquipmentConsent.class);
        util.exportExcel(response, list, "器材审批数据");
    }

    /**
     * 获取器材审批详细信息
     */
//    @RequiresPermissions("consent:consent:query")
    @GetMapping(value = "/{equipmentApplicationId}")
    public AjaxResult getInfo(@PathVariable("equipmentApplicationId") Long equipmentApplicationId)
    {
        return success(algsEquipmentConsentService.selectAlgsEquipmentConsentByEquipmentApplicationId(equipmentApplicationId));
    }

    /**
     * 新增器材审批
     */
//    @RequiresPermissions("consent:consent:add")
    @Log(title = "器材审批", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlgsEquipmentConsent algsEquipmentConsent)
    {
        return toAjax(algsEquipmentConsentService.insertAlgsEquipmentConsent(algsEquipmentConsent));
    }

    /**
     * 修改器材审批
     */
//    @RequiresPermissions("consent:consent:edit")
    @Log(title = "器材审批", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlgsEquipmentConsent algsEquipmentConsent)
    {
        return toAjax(algsEquipmentConsentService.updateAlgsEquipmentConsent(algsEquipmentConsent));
    }

    /**
     * 删除器材审批
     */
//    @RequiresPermissions("consent:consent:remove")
    @Log(title = "器材审批", businessType = BusinessType.DELETE)
	@DeleteMapping("/{equipmentApplicationIds}")
    public AjaxResult remove(@PathVariable Long[] equipmentApplicationIds)
    {
        return toAjax(algsEquipmentConsentService.deleteAlgsEquipmentConsentByEquipmentApplicationIds(equipmentApplicationIds));
    }
}
